﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" xmlns:SilverMap="clr-namespace:SilverMap;assembly=SilverMap" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:local="clr-namespace:SilverMap.Editor" x:Class="SilverMap.Editor.MainPage"
    d:DesignWidth="640" d:DesignHeight="480">
	<UserControl.Resources>
		<Style x:Key="TilesListItemStyle" TargetType="ListBoxItem">
			<Setter Property="Padding" Value="3"/>
			<Setter Property="HorizontalContentAlignment" Value="Left"/>
			<Setter Property="VerticalContentAlignment" Value="Top"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="TabNavigation" Value="Local"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="ListBoxItem">
						<Grid Background="{TemplateBinding Background}">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="fillColor" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value=".35"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="SelectionStates">
									<VisualState x:Name="Unselected"/>
									<VisualState x:Name="Selected">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="fillColor2" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value=".75"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="0">
													<DiscreteObjectKeyFrame.Value>
														<Visibility>Visible</Visibility>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Rectangle x:Name="fillColor" Fill="#FFBADDE9" RadiusX="1" RadiusY="1" IsHitTestVisible="False" Opacity="0" Visibility="Collapsed"/>
							<Rectangle x:Name="fillColor2" Fill="#FFBADDE9" RadiusX="1" RadiusY="1" IsHitTestVisible="False" Opacity="0" Visibility="Collapsed"/>
							<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Visibility="Collapsed"/>
							<Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="1" RadiusY="1" Visibility="Collapsed"/>
							<Image Margin="0" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Top" Source="{Binding Image, Mode=OneWay}"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="MenuItemButton" TargetType="Button">
			<Setter Property="Background" Value="#FF1F3B53"/>
			<Setter Property="Foreground" Value="#FF000000"/>
			<Setter Property="Padding" Value="3"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="BorderBrush">
				<Setter.Value>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFA3AEB9" Offset="0"/>
						<GradientStop Color="#FF8399A9" Offset="0.375"/>
						<GradientStop Color="#FF718597" Offset="0.375"/>
						<GradientStop Color="#FF617584" Offset="1"/>
					</LinearGradientBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid Cursor="Hand">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#F2FFFFFF"/>
											</ColorAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#CCFFFFFF"/>
											</ColorAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#7FFFFFFF"/>
											</ColorAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Pressed">
										<Storyboard>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#FF6DBDD1"/>
											</ColorAnimationUsingKeyFrames>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#D8FFFFFF"/>
											</ColorAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#C6FFFFFF"/>
											</ColorAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#8CFFFFFF"/>
											</ColorAnimationUsingKeyFrames>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Rectangle.Fill).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#3FFFFFFF"/>
											</ColorAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value=".55"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Unfocused"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Border x:Name="Background" Background="White" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" Visibility="Collapsed">
								<Grid Margin="1" Background="{TemplateBinding Background}">
									<Border x:Name="BackgroundAnimation" Opacity="0" Background="#FF448DCA"/>
									<Rectangle x:Name="BackgroundGradient">
										<Rectangle.Fill>
											<LinearGradientBrush EndPoint=".7,1" StartPoint=".7,0">
												<GradientStop Color="#FFFFFFFF" Offset="0"/>
												<GradientStop Color="#F9FFFFFF" Offset="0.375"/>
												<GradientStop Color="#E5FFFFFF" Offset="0.625"/>
												<GradientStop Color="#C6FFFFFF" Offset="1"/>
											</LinearGradientBrush>
										</Rectangle.Fill>
									</Rectangle>
								</Grid>
							</Border>
							<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
							<Rectangle x:Name="DisabledVisualElement" Fill="#FFFFFFFF" RadiusX="3" RadiusY="3" IsHitTestVisible="false" Opacity="0"/>
							<Rectangle x:Name="FocusVisualElement" Stroke="#FF6DBDD1" StrokeThickness="1" RadiusX="2" RadiusY="2" Margin="1" IsHitTestVisible="false" Opacity="0"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<Grid x:Name="LayoutRoot">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="0.788*"/>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="0.212*"/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="20"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>

		<StackPanel x:Name="MenuPanel" Margin="0" Orientation="Horizontal" Grid.ColumnSpan="3">
			<Button x:Name="NewMapButton" Style="{StaticResource MenuItemButton}" Width="16" Height="16" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTipService.ToolTip="New Map" Margin="4,0" Click="NewMapButton_Click">
				<Image Width="16" Height="16" Source="Assets/NewDocumentHS.png"/>
			</Button>
			<Button x:Name="OpenMapButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Open Map" Margin="4,0" Click="OpenMapButton_Click">
				<Image Height="16" Width="16" Source="Assets/openHS.png"/>
			</Button>
			<Button x:Name="SaveMapButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Save Map" Margin="4,0" Click="SaveMapButton_Click">
				<Image Height="16" Width="16" Source="Assets/saveHS.png"/>
			</Button>
			<Path Stretch="Fill" Stroke="White" Margin="0,2,0,1" Width="1" UseLayoutRounding="False" Data="M72,2 L72,18"/>
			<Button x:Name="SnapToGridButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Snap To Grid" Margin="4,0" Click="SnapToGridButton_Click">
				<Image Height="16" Width="16" Source="Assets/AlignToGridHS.png"/>
			</Button>
			<Button x:Name="GridLinesButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Grid Lines" Margin="4,0" Click="GridLinesButton_Click">
				<Image Height="16" Width="16" Source="Assets/ShowGridlines2HS.png"/>
			</Button>
			<Path Stretch="Fill" Stroke="White" Margin="0,2,0,1" Width="1" UseLayoutRounding="False" Data="M72,2 L72,18"/>
			<Button x:Name="SelectButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Select Tiles" Margin="4,0" Click="SelectButton_Click">
				<Image Height="16" Width="16" Source="Assets/PointerHS.png"/>
			</Button>
			<Button x:Name="DrawButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Draw Tiles" Margin="4,0" Click="DrawButton_Click">
				<Image Height="16" Width="16" Source="Assets/LineColorHS.png"/>
			</Button>
			<Path Stretch="Fill" Stroke="White" Margin="0,2,0,1" Width="1" UseLayoutRounding="False" Data="M72,2 L72,18"/>
			<Button x:Name="ShortcutsButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Show/Hide Shortcuts" Margin="4,0" Click="ShortcutsButton_Click">
				<Image Height="16" Width="16" Source="Assets/GotoShortcutsHS.png"/>
			</Button>
			<Button x:Name="GridDetailsButton" Height="16" HorizontalAlignment="Center" Style="{StaticResource MenuItemButton}" VerticalAlignment="Center" Width="16" ToolTipService.ToolTip="Grid Details" Margin="4,0" Click="GridDetailsButton_Click">
				<Image Height="16" Width="16" Source="Assets/ShowGridlinesHS.png"/>
			</Button>
		</StackPanel>

		<SilverMap:UIMap x:Name="Map" Grid.Row="1" MouseEnter="Map_MouseEnter" MouseLeave="Map_MouseLeave" MouseMove="Map_MouseMove" MouseLeftButtonDown="Map_MouseLeftButtonDown" MouseLeftButtonUp="Map_MouseLeftButtonUp"/>
		
		<controls:GridSplitter HorizontalAlignment="Right" Margin="0" Width="5" Grid.Row="1" Grid.Column="1"/>
		<ListBox x:Name="TilesList" Margin="0" Grid.Row="1" Grid.Column="2" Background="{x:Null}" BorderBrush="{x:Null}" ItemContainerStyle="{StaticResource TilesListItemStyle}" SelectionChanged="TilesList_SelectionChanged"/>
		<Canvas Margin="0" Grid.Row="1">
			<local:CursorIcon x:Name="CursorImage" Visibility="Collapsed" RenderTransformOrigin="0.5,0.5">
				<local:CursorIcon.RenderTransform>
					<TransformGroup>
						<ScaleTransform/>
						<SkewTransform/>
						<RotateTransform/>
						<TranslateTransform/>
					</TransformGroup>
				</local:CursorIcon.RenderTransform>
			</local:CursorIcon>
		</Canvas>
		<TextBlock x:Name="StatusLabel" HorizontalAlignment="Left" Margin="8,0,0,8" TextWrapping="Wrap" d:LayoutOverrides="Height" VerticalAlignment="Bottom" Grid.Row="1">
  		<TextBlock.Foreground>
  			<SolidColorBrush Color="{StaticResource TextColor}"/>
  		</TextBlock.Foreground>
		</TextBlock>
		<TextBlock x:Name="SnapToGridLabel" HorizontalAlignment="Right" Margin="8,0,8,26" TextWrapping="Wrap" VerticalAlignment="Bottom" Grid.Row="1" Text="Snap to Grid" Visibility="Collapsed">
  		<TextBlock.Foreground>
  			<SolidColorBrush Color="{StaticResource TextColor}"/>
  		</TextBlock.Foreground>
		</TextBlock>
		<TextBlock x:Name="ScaleLabel" HorizontalAlignment="Right" Margin="0,0,8,8" TextWrapping="Wrap" VerticalAlignment="Bottom" Grid.Row="1" Text="Map Scale: 1.0">
			<TextBlock.Foreground>
				<SolidColorBrush Color="{StaticResource TextColor}"/>
			</TextBlock.Foreground>
		</TextBlock>
		<TextBlock x:Name="ScalingLabel" HorizontalAlignment="Right" Margin="0,8,8,0" Text="Scaling" TextWrapping="Wrap" d:LayoutOverrides="Height" Grid.Row="1" VerticalAlignment="Top" FontSize="18.667" FontWeight="Bold" Visibility="Collapsed">
  		<TextBlock.Foreground>
  			<SolidColorBrush Color="{StaticResource AlertColor}"/>
  		</TextBlock.Foreground>
		</TextBlock>
		<TextBlock x:Name="RotatingLabel" HorizontalAlignment="Right" Margin="0,8,8,0" VerticalAlignment="Top" Grid.Row="1" FontSize="18.667" FontWeight="Bold" Text="Rotating" TextWrapping="Wrap" Visibility="Collapsed">
  		<TextBlock.Foreground>
  			<SolidColorBrush Color="{StaticResource AlertColor}"/>
  		</TextBlock.Foreground>
		</TextBlock>
		<TextBlock x:Name="LayerLabel" HorizontalAlignment="Left" Margin="8,8,0,0" Text="Layer 0" TextWrapping="Wrap" d:LayoutOverrides="Height" Grid.Row="1" VerticalAlignment="Top">
  		<TextBlock.Foreground>
  			<SolidColorBrush Color="{StaticResource TextColor}"/>
  		</TextBlock.Foreground>
		</TextBlock>
		<StackPanel x:Name="ShortCutsPanel" HorizontalAlignment="Left" Margin="8,32,0,32" Grid.Row="1" Opacity="0.6">
			<StackPanel VerticalAlignment="Top" Orientation="Horizontal">
				<Image Height="16" Margin="0,0,8,0" Width="16" Source="Assets/GotoShortcutsHS.png"/>
				<TextBlock Text="Common" TextWrapping="Wrap" FontWeight="Bold">
  				<TextBlock.Foreground>
  					<SolidColorBrush Color="{StaticResource HeadingColor}"/>
  				</TextBlock.Foreground>
				</TextBlock>
			</StackPanel>
			<TextBlock Text="K = Layer Down" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="L = Layer Up" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="N = Reset Scale/Rotation/Opacity" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="S = Scale" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="R = Rotate" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="X = Z-Index Down" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="Z = Z-Index Up" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="PgUp = Zoom Out" TextWrapping="Wrap">
				<TextBlock.Foreground>
					<SolidColorBrush Color="{StaticResource TextColor}"/>
				</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="PgDn = Zoom In" TextWrapping="Wrap">
				<TextBlock.Foreground>
					<SolidColorBrush Color="{StaticResource TextColor}"/>
				</TextBlock.Foreground>
			</TextBlock>
			<StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="0,8,0,0">
				<Image Height="16" Margin="0,0,8,0" Width="16" Source="Assets/PointerHS.png"/>
				<TextBlock Text="Selection Mode" TextWrapping="Wrap" FontWeight="Bold">
  				<TextBlock.Foreground>
  					<SolidColorBrush Color="{StaticResource HeadingColor}"/>
  				</TextBlock.Foreground>
				</TextBlock>
			</StackPanel>
			<TextBlock Text="Del = Delete Item" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<TextBlock Text="Arrows = Adjust Selected Item" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
			<StackPanel VerticalAlignment="Top" Orientation="Horizontal" Margin="0,8,0,0">
				<Image Height="16" Margin="0,0,8,0" Width="16" Source="Assets/LineColorHS.png"/>
				<TextBlock Text="Drawing Mode" TextWrapping="Wrap" FontWeight="Bold">
  				<TextBlock.Foreground>
  					<SolidColorBrush Color="{StaticResource HeadingColor}"/>
  				</TextBlock.Foreground>
				</TextBlock>
			</StackPanel>
			<TextBlock Text="Arrows = Move Map" TextWrapping="Wrap">
  			<TextBlock.Foreground>
  				<SolidColorBrush Color="{StaticResource TextColor}"/>
  			</TextBlock.Foreground>
			</TextBlock>
		</StackPanel>

	</Grid>
</UserControl>
